package com.ganee.agora.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.ganee.agora.model.CollectActivityEntity;
import com.ganee.agora.model.HomeListBean;
import com.ganee.agora.model.InsertActivityEntity;
import com.ganee.agora.model.TicketInfoEntity;
import com.ganee.agora.repository.HomeRepository;
import com.ganee.agora.repository.SettingsRepository;
import com.ganee.baselib.httprequest.callback.RequestCallback;
import com.ganee.baselib.httprequest.callback.RequestMultiplyCallback;
import com.ganee.baselib.httprequest.exception.ApiException;
import com.ganee.baselib.httprequest.utils.ToastUtil;
import com.ganee.baselib.mvvmlibrary.base.BaseViewModel;

import java.util.List;

public class HomeViewModel extends BaseViewModel<HomeRepository> {

    private  MutableLiveData<List<HomeListBean>> homeList = new MutableLiveData<>();
    public  MutableLiveData<List<InsertActivityEntity>> hostEvent = new MutableLiveData<>();
    public  MutableLiveData<List<InsertActivityEntity>> collect = new MutableLiveData<>();
    public  MutableLiveData<List<InsertActivityEntity>> registration = new MutableLiveData<>();


    public HomeViewModel(@NonNull Application application) {
        super(application);
    }

    @Override
    protected HomeRepository getRepository() {
        return new HomeRepository(this);
    }

    //首页列表
    public void getHomeList() {
        mRepository.getHomeList(new RequestCallback<List<HomeListBean>>() {

            @Override
            public void onSuccess(List<HomeListBean> companyEntityList) {
                homeList.setValue(companyEntityList);
            }
        });
    }

    //已发布列表
    public void getHostEventList() {
        mRepository.getHostEventList(new RequestCallback<List<InsertActivityEntity>>() {

            @Override
            public void onSuccess(List<InsertActivityEntity> companyEntityList) {
                hostEvent.setValue(companyEntityList);
            }
        });
    }

    //收藏列表
    public void getCollectList() {
        mRepository.getCollectList(new RequestCallback<List<InsertActivityEntity>>() {

            @Override
            public void onSuccess(List<InsertActivityEntity> companyEntityList) {
                collect.setValue(companyEntityList);
            }
        });
    }

    //已报名列表
    public void getRegistrationsList() {
        mRepository.getRegistrationsList(new RequestCallback<List<InsertActivityEntity>>() {

            @Override
            public void onSuccess(List<InsertActivityEntity> companyEntityList) {
                registration.setValue(companyEntityList);
            }
        });
    }

    public MutableLiveData<List<HomeListBean>> getHome(){
        return homeList;
    }


    //过期票列表
    public void postPastTicketList(RequestCallback<List<TicketInfoEntity>> callback) {
        mRepository.postPastTicketList(callback);
    }

    //upComming票
    public void postUpCommingTicketList(RequestCallback<List<TicketInfoEntity>> callback) {
        mRepository.postUpCommingTicketList(callback);
    }
}
